




import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

import java.math.BigDecimal;
import java.util.regex.Pattern;

public class grade1 {
	private Selenium selenium;
   

	@Before
	public void setUp() throws Exception {
		selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.back2college.com/");
		selenium.start();
			}
		public double totalgrade(String tg)
			{
			if (tg=="A")
			 {
				return 4;
		      }
			if (tg=="A-")
		     {
				return  3.70;
			  }
			if(tg=="B+")
			  {
				return  3.33;
				}
			 if (tg=="B")
			{
			 	return 3;
			}	
			if(tg=="B-")
			{
					return 2.70; 
			}
			if(tg=="C+")
			{
				return  2.30;
				}
			if(tg=="C")
			{
				return 2;
			}
				if(tg=="C-")
				{
					return 1.70;
				}
				if (tg=="D+")
				{
					return 1.30;
					}
				
				if(tg=="D")
				{ 
					return 1.00;
				}
					if(tg=="D-")
					{
						return 0.70;
					}
					else 
					{
							 return 0;
					}

					}
				

	

	@Test
	public void testGsu() throws Exception {
		selenium.open("http://www.back2college.com/gpa.htm");
			String[] tc={("English"), ("Maths"), ("Physics"), ("Chemistry"),("Botany"), ("Zoology"), ("Tamil")};
			String[] tch={"4","3","3","4","3","3","3"};
			String[] tg={"A","A","A","B+","B","A","B"};
			double tgp1=0;double tgp=0;
			for(int i =0; i<=6; i++){
				
		teststep(tc[i],tch[i],tg[i]);
		tgp1+=tgp*(Double.parseDouble(tch[i]));
		System.out.println("tgp1 "+tgp1);
			}
		
		/*	
		double tch =Double.parseDouble(tch1)+Double.parseDouble(tch2)+Double.parseDouble(tch3)+Double.parseDouble(tch4)+
		Double.parseDouble(tch5)+Double.parseDouble(tch6)+Double.parseDouble(tch7);
		System.out.println("grand credit hours " + tch); 
		
		double ggpt=tgp1+tgp2+tgp3+tgp4+tgp5+tgp6+tgp7;
		System.out.println("grand gradepoint total "+ ggpt);*/
	/*			
		double gpa = ggpt/tch;
		BigDecimal bd =new  BigDecimal(gpa);
		 bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
		gpa = bd.doubleValue();
		System.out.println("gpa is "+gpa);
			}
		*/
	}

	@After
	public void tearDown() throws Exception {
		
		System.out.println("done");
	
	}
	public double teststep(String vtc,String vtch,String vtg ){
		int j;
		for(j=1; j<=6; j++)
		selenium.type("course"+j, vtc);
		selenium.type("credithours"+j,vtch);
		selenium.select("grade"+j, vtg);
		System.out.println("course1 info entered: " +vtc);
		return totalgrade (vtg);
		
	}
	public String finale(){
		return("done");
		
	}
	}
